package com.lwx.sys.controller;


import com.lwx.sys.service.LoginfoService;
import com.lwx.sys.utils.DataGridView;
import com.lwx.sys.utils.ResultObj;
import com.lwx.sys.vo.LoginfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录日志管理
 * @author lwx
 * @since 2020-04-07
 */
@RestController
@RequestMapping("/loginfo")
public class LoginfoController {

    @Autowired
    private LoginfoService loginfoService;

    /**
     * 加载所有日志
     * @param loginfoVo
     * @return
     */
    @GetMapping("/loadAllLoginfo")
    public DataGridView loadAllLoginfo(LoginfoVo loginfoVo){
       return loginfoService.loadAllLoginfo(loginfoVo);
    }

    /**
     * 删除日志
     * @param id
     * @return
     */
    @DeleteMapping("/deleteLoginfo")
    public ResultObj deleteLoginfo(Integer id){
        try {
            loginfoService.deleteLoginfo(id);
            return ResultObj.DELETE_SUCESS;
        }catch (Exception e){
            return ResultObj.DELETE_ERROR;
        }
    }

    /**
     * 批量删除日志
     * @param ids
     * @return
     */
    @DeleteMapping("/batchDeleteLoginfo")
    public ResultObj batchDeleteLoginfo(Integer[] ids){
        try {
            loginfoService.batchDeleteLoginfo(ids);
            return ResultObj.DELETE_SUCESS;
        }catch (Exception e){
            return ResultObj.DELETE_ERROR;
        }
    }
}

